package com.woniuxy.service.impl;

import com.woniuxy.entity.Ordermanage;
import com.woniuxy.dao.OrdermanageDao;
import com.woniuxy.service.OrdermanageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Ordermanage)表服务实现类
 *
 * @author makejava
 * @since 2021-05-24 15:49:47
 */
@Service("ordermanageService")
public class OrdermanageServiceImpl implements OrdermanageService {
    @Resource
    private OrdermanageDao ordermanageDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderId 主键
     * @return 实例对象
     */
    @Override
    public Ordermanage queryById(Integer orderId) {
        return this.ordermanageDao.queryById(orderId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Ordermanage> queryAllByLimit(int offset, int limit) {
        return this.ordermanageDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ordermanage 实例对象
     * @return 实例对象
     */
    @Override
    public Ordermanage insert(Ordermanage ordermanage) {
        this.ordermanageDao.insert(ordermanage);
        return ordermanage;
    }

    /**
     * 修改数据
     *
     * @param ordermanage 实例对象
     * @return 实例对象
     */
    @Override
    public Ordermanage update(Ordermanage ordermanage) {
        this.ordermanageDao.update(ordermanage);
        return this.queryById(ordermanage.getOrderId());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer orderId) {
        return this.ordermanageDao.deleteById(orderId) > 0;
    }

    @Override
    public List<Ordermanage> quaryAllOrder() {
        List<Ordermanage> ordermanages = this.ordermanageDao.quaryAllOrder();
        return ordermanages;
    }

    @Override
    public List<Ordermanage> queryAll(Ordermanage ordermanage) {
        List<Ordermanage> ordermanages = this.ordermanageDao.queryAll(ordermanage);
        return ordermanages;
    }

    /**
     * Auther: Hello Mr. Guo  <br/>
     * Date: 10:46:2021/5/25  <br/>
     * Description:父子订单连表查询
     */
    @Override
    public List<Ordermanage> selectAllOrder(Ordermanage ordermanage) {
        List<Ordermanage> ordermanages = this.ordermanageDao.selectAllOrder(ordermanage);
        return ordermanages;
    }

    /**
     * 通过房间id查询大订单的id
     *
     * @param orderRoomid 实例对象
     * @return 对象
     */
    @Override
    public Ordermanage selectordermanageidbyroomid(Integer orderRoomid) {
        return this.ordermanageDao.selectordermanageidbyroomid(orderRoomid);
    }
}
